package com.gite.nouette.admin.implementation.integrator.assembler;

import com.gite.nouette.admin.contract.application.init.IInitializerAdmin;
import com.gite.nouette.admin.contract.integrator.assembler.IAssemblerAdmin;
import com.gite.nouette.admin.contract.integrator.director.IDirectorAdmin;
import com.gite.nouette.admin.contract.integrator.factory.IFactoryModel;
import com.gite.nouette.admin.implementation.integrator.builder.BuilderAdminImpl;
import com.gite.nouette.admin.implementation.integrator.director.DirectorAdminImpl;

public class AssemblerAdminImpl implements IAssemblerAdmin {
	private IInitializerAdmin parentProduct;
	private IDirectorAdmin director;

	public AssemblerAdminImpl(IFactoryModel factoryModel) {
		setDirector(new DirectorAdminImpl());
		getDirector().setBuilder(new BuilderAdminImpl(factoryModel));
	}

	@Override
	public IInitializerAdmin getParentProduct() {
		return this.parentProduct;
	}

	@Override
	public void setParentProduct(IInitializerAdmin parentProduct) {
		this.parentProduct = parentProduct;
	}

	@Override
	public IDirectorAdmin getDirector() {
		return this.director;
	}

	private void setDirector(IDirectorAdmin director) {
		this.director = director;
	}

	@Override
	public void run() {
		getDirector().constructProduct();
		getParentProduct().setAdmin(getDirector().getProduct());
	}
}
